#ifndef CONTOUR_H_INCLUDED
#define CONTOUR_H_INCLUDED

#include <list>
#include "types.h"
#include "image.h"
using namespace std;

/**\file contour.h
*  \brief Definition of contour objects */

/** \class Contour
*   \brief This class define a object which stores contour of an image
*/

class Contour{
    private:
        ///If is closed or not
        bool isclosed;
        ///Identify the contour, case an image has more than one
        int label;
        /**Size of pixel in real world.
        In meters*/
        float pixelsize;
        ///Size of curve in pixels
        int pixel_lenght;
        ///The origin of image, 1 if is upper-left, 2 if is lower-left
        int origin;

    public:
        ///Binary image of contour: false(0) if pixel is not a contour, true(1) if is a contour.
        Binary_Image *img;
        ///Has the list of points in parametric contour
        list<Position> points;

        ///Constructor
        ///Caution: Final users, don't use this constructors
        Contour();

        ///Constructor
        ///Caution: Final users, don't use this constructors
        /**\param image A defined image. Constructor will get informations of height and width for Binary_Image of contour
        Put the image which create this contour*/
        Contour(Image *image);

        ///Constructor
        ///Caution: Final users, don't use this constructors
        ///\param ymax Max height for the Binary_Image of contour.Put the max height of the image that create this contour
        ///\param xmax Max width for the Binary_Image of contour.Put the max width of the image that create this contour
        Contour(int ymax,int xmax);

        ~Contour();

        ///Add a pointer to contour
        ///\param point Point that will be added
        void addPoint(Position point);

        ///Add a pointer to contour
        ///\param x Coordinate x of point that will be added
        ///\param y Coordinate y of point that will be added
        void addPoint(int x,int y);

        ///Get the contour of a Grey_Image
        ///Must be a unique connected shape
        ///\param image Pointer to Grey_Image
        ///\param label Label that identify the object of image
        ///\param neightbourhood Connectivity. Default = 8 conex
        ///\return Pointer to new extracted Contour
        static Contour* newFromImage(Grey_Image *image,unsigned int label,int neightbourhood=EIGHTNEIGHBOURHOOD);

        ///Get the contour of a Binary_Image
        ///Must be a unique connected shape
        ///\param image Pointer to Grey_Image
        ///\param neightbourhood Connectivity. Default = 8 conex
        ///\return Pointer to new extracted Contour
        static Contour* newFromImage(Binary_Image *image,int neightbourhood=EIGHTNEIGHBOURHOOD);

        ///Get the contour from file
        ///Must be a unique connected shape
        ///\param filename filename with your path
        ///\return Pointer to new extracted Contour
        static Contour* newFromFile(char* filename);

        ///Save the contour in a file
        ///\param filename filename with your path
        void saveInFile(char* filename);

        ///Say if contour is closed
        ///\return return true if is closed
        bool isClosed() const;

        ///Set closed propriety
        ///\param true or false
        void setClosed(bool b);

        ///Get label of this contour
        ///\return return the label
        int getLabel() const;

        ///Set label of contour
        ///\param The Label
        void setLabel(int l);

        ///Get the size of pixel in real world
        ///\return Return size in meters
        float getPixelSize() const;

        ///set the size of pixel in real world
        ///\param size in meters
        void setPixelSize(float s);

        ///Get the lenght of contour in number of pixels
        ///\return return the number of pixels
        int getPixelLenght() const;

        ///Set the lenght of contour in number of pixels
        ///\param the number of pixels
        void setPixelLenght(int l);

        ///Get the param which describe origin
        ///\return 1 if is upper-left, 2 if is lower-left
        int getOrigin() const;

        ///Set the param which describe origin
        ///\param 1 if is upper-left, 2 if is lower-left
        void setOrigin(int o);


};

#endif // CONTOUR_H_INCLUDED
